﻿using RecruitStudents.Utility;
using RecruitStudents.Utility.Helper;
using RecruitStudents.Utility.Json;
using RecruitStudents.Utility.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RecruitStudents.Client.BLL
{
    public class ServiceOnSiteSign
    {
        WS_OnSiteSign.OnSiteSignService onSiteSignService = new WS_OnSiteSign.OnSiteSignService();
        WS_OnSiteSign.MySoapHeader objHeader = new WS_OnSiteSign.MySoapHeader();
        internal ServiceOnSiteSign()
        {
            objHeader.Username = "admin";
            objHeader.Password = "xy";
            onSiteSignService.MySoapHeaderValue = objHeader;
        }
        public DataTable GetTB_Pad_Examing(string strSignedID, string strExamRoomNO, string strExamYear)
        {
            return onSiteSignService.GetTB_Pad_Examing(strSignedID, strExamRoomNO, strExamYear).ToDataTable();
        }
        public DataTable GetTB_Pad_SignedTableTopOne_New(string strEntretenimientohID, string strExamYear)
        {
            return onSiteSignService.GetTB_Pad_SignedTableTopOne_New(strEntretenimientohID, strExamYear).ToDataTable();
        }

        public TB_Exam_Signed GetExamSignedByID(string strSignedID, string strExamYear)
        {
            return onSiteSignService.GetExamSignedByID(strSignedID, strExamYear).ToList<TB_Exam_Signed>();
        }

        public DataTable CheckTB_Pad_Signed_New(string SpecialityKindsNO, string ExamLevel, string ExamPlaceNO, string idCard, string strExamYear)
        {
            return onSiteSignService.CheckTB_Pad_Signed_New(SpecialityKindsNO, ExamLevel, ExamPlaceNO, idCard, strExamYear).ToDataTable();
        }
        internal DataTable GetTB_Pad_SignedTable_New(string strEntretenimientohID, string strExamYear)
        {
            return onSiteSignService.GetTB_Pad_SignedTable_New(strEntretenimientohID, strExamYear).ToDataTable();
        }

        internal DataTable CheckTB_Pad_Signed(string SpecialityKindsNO, string ExamLevel, string ExamPlaceNO, string idCard)
        {
            return onSiteSignService.CheckTB_Pad_Signed(SpecialityKindsNO, ExamLevel, ExamPlaceNO, idCard).ToDataTable();
        }

        internal DataTable GetTB_Pad_SignedTableByIdCard(string strEntretenimientohID, string strIdentityCard, string strExamYear)
        {
            return onSiteSignService.GetTB_Pad_SignedTableByIdCard(strEntretenimientohID, strIdentityCard, strExamYear).ToDataTable();
        }
        internal DataTable GetTB_Pad_SignedTableTopOne(string strEntretenimientohID, string isOrder)
        {
            return onSiteSignService.GetTB_Pad_SignedTableTopOne(strEntretenimientohID, isOrder).ToDataTable();
        }

        internal DataTable GetTB_Pad_SignedTable(string strEntretenimientohID, string isOrder)
        {
            return onSiteSignService.GetTB_Pad_SignedTable(strEntretenimientohID, isOrder).ToDataTable();
        }

        internal DataTable GetCombinationData(string strExamRoomNo, string strExamYear)
        {
            return onSiteSignService.GetCombinationData(strExamRoomNo, strExamYear).ToDataTable();
        }

        internal int GetQueueCount(string ExamRoomID)
        {
            return onSiteSignService.GetQueueCount(ExamRoomID);
        }

        internal bool UpdateExamSigned(string strSignedID, string strYear)
        {
            try
            {
                var result = onSiteSignService.UpdateExamSigned(strSignedID, strYear).ToList<JsonMessage>();
                if (result.State.ToLower() == "false")
                {
                    DevHelper.ShowErrorMessageBox(result.Msg);
                    return false;
                }
                else
                {
                    DevHelper.ShowInfoMessageBox(result.Msg);
                    return true;
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox("操作数据出现错误:" + ex.Message);
                DevHelper.HideWaiting();
                return false;
            }
        }

        internal bool SaveExamSigned(TB_Exam_Signed model)
        {
            try
            {
                var result = onSiteSignService.SaveExamSigned(model.ToJson()).ToList<JsonMessage>();
                if (result.State.ToLower() == "false")
                {
                    DevHelper.ShowErrorMessageBox(result.Msg);
                    return false;
                }
                else
                {
                    DevHelper.ShowInfoMessageBox(result.Msg);
                    return true;
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox("操作数据出现错误:" + ex.Message);
                DevHelper.HideWaiting();
                return false;
            }
        }

        internal bool DeleteExamSigned(string strSignedID)
        {
            try
            {
                var result = onSiteSignService.DeleteExamSigned(strSignedID).ToList<JsonMessage>();
                if (result.State.ToLower() == "false")
                {
                    DevHelper.ShowErrorMessageBox(result.Msg);
                    return false;
                }
                else
                {
                    DevHelper.ShowInfoMessageBox(result.Msg);
                    return true;
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox("操作数据出现错误:" + ex.Message);
                DevHelper.HideWaiting();
                return false;
            }
        }

        internal bool SavePadQueue(TB_Pad_Queue strJson)
        {
            try
            {
                var result = onSiteSignService.SavePadQueue(strJson.ToJson()).ToList<JsonMessage>();
                if (result.State.ToLower() == "false")
                {
                    //DevHelper.ShowErrorMessageBox(result.Msg);
                    return false;
                }
                else
                {
                    //DevHelper.ShowInfoMessageBox(result.Msg);
                    return true;
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox("操作数据出现错误:" + ex.Message);
                DevHelper.HideWaiting();
                return false;
            }
        }

        internal bool SavePadQueueBySignedID(string strSignedID, string ExamRoomID)
        {
            try
            {
                var result = onSiteSignService.SavePadQueueBySignedID(strSignedID, ExamRoomID).ToList<JsonMessage>();
                if (result.State.ToLower() == "false")
                {
                    //DevHelper.ShowErrorMessageBox(result.Msg);
                    return false;
                }
                else
                {
                    //DevHelper.ShowInfoMessageBox(result.Msg);
                    return true;
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox("操作数据出现错误:" + ex.Message);
                DevHelper.HideWaiting();
                return false;
            }
        }

        internal bool DeletePadQueue(string strSignedID)
        {
            try
            {
                var result = onSiteSignService.DeletePadQueue(strSignedID).ToList<JsonMessage>();
                if (result.State.ToLower() == "false")
                {
                    //DevHelper.ShowErrorMessageBox(result.Msg);
                    return false;
                }
                else
                {
                    //DevHelper.ShowInfoMessageBox(result.Msg);
                    return true;
                }
            }
            catch (Exception ex)
            {
                DevHelper.ShowErrorMessageBox("操作数据出现错误:" + ex.Message);
                DevHelper.HideWaiting();
                return false;
            }
        }
    }
}
